/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: CanTpCfg.h
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: CanTp
*
*******************************************************************************/

#ifndef CANTPCFG_H
#define CANTPCFG_H

/** HEADER FILES **/
#include "CanTpType.h"
#include "CanTpRte.h" 


/** MACRO DEFINITION **/
#define CanTpConf_CanTpChannel_Tx 0u
#define CanTpConf_CanTpChannel_Tx_Max 1u

#define CanTpConf_CanIfRxPduCfg_Pdu_Channel1_Tester_DiagFuncRequest 0u
#define CanTpConf_CanIfRxPduCfg_Pdu_Channel1_Tester_DiagPhysRequest 1u
#define CanTpConf_CanTpChannel_Rx_Max 2u


/** TYPEDEF DEFINITION **/
typedef struct
{
    uint8 CanTpPaddingByte;
}CanTpGeneralType;


typedef uint8 CanTpAddressingFormatType;
#define CANTP_EXTENDED ((CanTpAddressingFormatType)0x00)  /* Extended addressing format */
#define CANTP_MIXED ((CanTpAddressingFormatType)0x01) /* Mixed 11 bit addressing format */
#define CANTP_MIXED29BIT ((CanTpAddressingFormatType)0x02) /* Mixed 29 bit addressing format */
#define CANTP_NORMALFIXED ((CanTpAddressingFormatType)0x03) /* Normal fixed addressing format */
#define CANTP_STANDARD ((CanTpAddressingFormatType)0x04) /* Normal addressing format */

typedef uint8 CanTpTaTypeType;
#define CANTP_PHYSICAL ((CanTpTaTypeType)0x00) /* Physical request type */
#define CANTP_FUNCTIONAL ((CanTpTaTypeType)0x01) /* Functional request type */

typedef struct
{
    PduType* CanTpTxFcNPduRef;
    uint16 CanTpTxFcNPduConfirmationPduId; /* Handle Id to be used by the CanIf to confirm the transmission of the CanTpTxFcNPdu to the CanIf module */  
}CanTpTxFcNPduType;


typedef struct
{
    PduType* CanTpRxNPduRef;
    uint16 CanTpRxNPduId;
}CanTpRxNPduType;


typedef struct
{
    PduType* CanTpRxNSduRef; /* Reference to a Pdu in the COM-Stack */
    CanTpRxNPduType CanTpRxNPdu;
    CanTpTxFcNPduType CanTpTxFcNPdu;
    uint16 CanTpRxNSduId; /* Unique identifier user by the upper layer to call CanTp_CancelReceive, CanTp_ ChangeParameter and CanTp_ReadParameter */
    uint16 CanTpRxWftMax; /* This parameter indicates how many Flow Control wait N-PDUs can be consecutively transmitted by the receiver */
    uint8 CanTpBs; /* Sets the number of N-PDUs the CanTp receiver allows the sender to send */
    uint8 CanTpNar; /* Value in seconds of the N_Ar timeout */
    uint8 CanTpNbr; /* Value in seconds of the performance requirement for (N_Br + N_Ar) */
    uint8 CanTpNcr; /* Value in seconds of the N_Cr timeout */
    uint8 CanTpSTmin; /* Sets the duration of the minimum time the CanTp sender shall wait between the transmissions of two CF N-PDUs */
    CanTpTaTypeType CanTpRxTaType; /* Declares the communication type of this Rx N-SDU */
    CanTpAddressingFormatType CanTpRxAddressingFormat;
}CanTpRxNSduType;

typedef struct
{
    PduType* CanTpTxNPduRef;
    uint16 CanTpTxNPduConfirmationPduId; /* Handle Id to be used by the CanIf to confirm the transmission of the CanTpTxNPdu to the CanIf module */
}CanTpTxNPduType;


typedef struct
{
    PduType* CanTpTxFcNPduRef;
    uint16 CanTpRxFcNPduId; /* N-PDU identifier attached to the FC N-PDU of this TxNsdu identified by CanTpTxNSdu Id. */  
}CanTpRxFcNPduType;


typedef struct
{
    PduType* CanTpTxNSduRef; /* Reference to a Pdu in the COM-Stack */
    CanTpTxNPduType CanTpTxNPdu;
    CanTpRxFcNPduType CanTpRxFcNPdu;
    uint16 CanTpTxNSduId; /* Unique identifier to a structure that contains all useful information to process the transmission of a TxNsdu */
    uint16 CanTpRxWftMax; /* This parameter indicates how many Flow Control wait N-PDUs can be consecutively transmitted by the receiver */
    uint8 CanTpNas; /* Value in second of the N_As timeout */
    uint8 CanTpNbs; /* Value in seconds of the N_Bs timeout */
    uint8 CanTpNcs; /* Value in seconds of the performance requirements relating to N_Cs */
    uint8 CanTpNAe; 
    uint8 CanTpNSa; 
    uint8 CanTpNTa; 
    CanTpTaTypeType CanTpTxTaType; /* Declares the communication type of this TxNsdu */
    CanTpAddressingFormatType CanTpTxAddressingFormat;
}CanTpTxNSduType;


typedef struct
{
    uint8 test;
}CanTp_ConfigType;


typedef struct
{
    CanIf_TxIndexType CanIfIndex;
}CanTp_TxConfigType;


typedef struct
{
    CanIf_RxIndexType CanIfIndex;
}CanTp_RxConfigType;

/** LOCAL DATA DEFINITION **/
extern const CanTp_TxConfigType CanTp_TxConfig[CanTpConf_CanTpChannel_Tx_Max];
extern const CanTpGeneralType CanTpGeneral;

extern const CanTpRxNSduType CanTpRxNSduConfig[CanTpConf_CanTpChannel_Rx_Max];
extern const CanTpTxNSduType CanTpTxNSduConfig[CanTpConf_CanTpChannel_Tx_Max];


#endif
